What's the purpose of having a separate "operator new[]" ?
Posted
by sharptooth
on Stack Overflow
See other posts from Stack Overflow
or by sharptooth
Published on 2010-03-23T12:43:03Z
Indexed on
2010/03/23
13:13 UTC
Read the original article
Hit count: 288
Looks like operator new
and operator new[]
have exactly the same signature:
void* operator new( size_t size );
void* operator new[]( size_t size );
and do exactly the same: either return a pointer to a big enough block of raw (not initialized in any way) memory or throw an exception.
Also operator new
is called internally when I create an object with new
and operator new[]
- when I create an array of objects with new[]
. Still the above two special functions are called by C++ internally in exactly the same manner and I don't se how the two calls can have different meanings.
What's the purpose of having two different functions with exactly the same signatures and exactly the same behavior?
© Stack Overflow or respective owner